#ifndef HANDLEMPLAYER_H
#define HANDLEMPLAYER_H

#include <QObject>
#include <QProcess>
#include <QTimer>
#include <QMainWindow>
#include "mplayerwrapper.h"
#include "mdiareaplayer.h"

class HandleMplayer : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString loadingType READ loadingType())
    Q_PROPERTY(QString loadingVideoId READ loadingVideoId())


public:
    HandleMplayer(MPlayerWrapper* pPlayer, MdiAreaPlayer* displayPlayer , QObject *parent=0);
    ~HandleMplayer();
    Q_INVOKABLE QString loadingType();
    Q_INVOKABLE QString loadingVideoId();

    /*void showProgressBar();
    void hideProgressBar();*/

    /*
      0 --> noList
      1 --> regular list elt
      2 --> first list elt
      3 --> last list elt
      */
    Q_INVOKABLE void loadNowVideo(QString videoType, QString videoId, int listState=0);


signals:
    void started();

    void nextAsked(QString videoType);
    void prevAsked(QString videoType);

    void failedToLoad(QString errDesc);
    void allFinished(QString videoType);
    void keyEvent(int key,QString videoType);
    //void onHome();

private slots:
    void finishToLoad(); //lorsque la video est finie d'être lue
    void displayKeyEvent(int keyCode);// lorsqu on recoit un evenement clavier de la fenetre qui joue la video

private:
    QString typeLoading, vIdLoading, lastLoadingType ;
    int listStatePlaying;
    MPlayerWrapper* player ; //attention ici mettre interface si on veut utiliser un autre player



};

#endif // HANDLEMPLAYER_H
